package com.ruoyi.sys.vehile.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sys.vehile.domain.TbTheAlarmRecord;
import com.ruoyi.sys.vehile.service.ITbTheAlarmRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警记录（进出口）Controller
 *
 * @author ruoyi
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/system/record1")
public class TbTheAlarmRecordController extends BaseController
{
    @Autowired
    private ITbTheAlarmRecordService tbTheAlarmRecordService;

    /**
     * 查询报警记录（进出口）列表
     */
    @PreAuthorize("@ss.hasPermi('system:record1:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbTheAlarmRecord tbTheAlarmRecord)
    {
        startPage();
        List<TbTheAlarmRecord> list = tbTheAlarmRecordService.selectTbTheAlarmRecordList(tbTheAlarmRecord);
        return getDataTable(list);
    }

    /**
     * 导出报警记录（进出口）列表
     */
    @PreAuthorize("@ss.hasPermi('system:record1:export')")
    @Log(title = "报警记录（进出口）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbTheAlarmRecord tbTheAlarmRecord)
    {
        List<TbTheAlarmRecord> list = tbTheAlarmRecordService.selectTbTheAlarmRecordList(tbTheAlarmRecord);
        ExcelUtil<TbTheAlarmRecord> util = new ExcelUtil<TbTheAlarmRecord>(TbTheAlarmRecord.class);
        util.exportExcel(response, list, "报警记录（进出口）数据");
    }

    /**
     * 获取报警记录（进出口）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:record1:query')")
    @GetMapping(value = "/{trId}")
    public AjaxResult getInfo(@PathVariable("trId") Long trId)
    {
        return AjaxResult.success(tbTheAlarmRecordService.selectTbTheAlarmRecordByTrId(trId));
    }

    /**
     * 新增报警记录（进出口）
     */
    @PreAuthorize("@ss.hasPermi('system:record1:add')")
    @Log(title = "报警记录（进出口）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbTheAlarmRecord tbTheAlarmRecord)
    {
        return toAjax(tbTheAlarmRecordService.insertTbTheAlarmRecord(tbTheAlarmRecord));
    }

    /**
     * 修改报警记录（进出口）
     */
    @PreAuthorize("@ss.hasPermi('system:record1:edit')")
    @Log(title = "报警记录（进出口）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbTheAlarmRecord tbTheAlarmRecord)
    {
        return toAjax(tbTheAlarmRecordService.updateTbTheAlarmRecord(tbTheAlarmRecord));
    }

    /**
     * 删除报警记录（进出口）
     */
    @PreAuthorize("@ss.hasPermi('system:record1:remove')")
    @Log(title = "报警记录（进出口）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trIds}")
    public AjaxResult remove(@PathVariable Long[] trIds)
    {
        return toAjax(tbTheAlarmRecordService.deleteTbTheAlarmRecordByTrIds(trIds));
    }
}
